package android.medicalcloud.com.yiapp.yilian.ui.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.medicalcloud.com.yiapp.R;
import android.view.Gravity;
import android.widget.TextView;




/**
 * 自定义 progressdialog
 */
public class RunProgressDialog {


    private Dialog customProgressDialog = null;


    public Dialog createDialog(Context context) {
        customProgressDialog = new Dialog(context, R.style.CustomProgressDialog);
        customProgressDialog.setContentView(R.layout.view_load_dialog);
        customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;
        return customProgressDialog;

    }

    public Dialog getCustomProgressDialog() {
        return customProgressDialog;
    }

    /**
     * [Summary]
     * <p>
     * setMessage 提示内容
     *
     * @param strMessage
     * @return
     */

    public synchronized RunProgressDialog setMessage(String strMessage) {

        TextView tvMsg = (TextView) customProgressDialog.findViewById(R.id.id_tv_loadingmsg);


        if (tvMsg != null) {

            tvMsg.setText(strMessage);

        }


        return this;

    }

    public void show() {
        if (!customProgressDialog.isShowing())
            customProgressDialog.show();
    }

    public void dismiss() {
        if (customProgressDialog.isShowing())
            customProgressDialog.dismiss();
    }


}
